package com.penglecode.spring3.jdbc.examples;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.penglecode.spring3.jdbc.AutoBoxingRowMapper;
import com.penglecode.spring3.jdbc.bean.User;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:com/penglecode/spring3/jdbc/applicationContext-jdbc.xml"})
public class JdbcExample1 {

	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	@Test
	public void test1(){
		String sql = "select a.user_id,a.user_name, a.password , b.id \"account.accountId\", b.status \"account.status\", b.amount \"account.amount\" from t_user a, t_account b where a.account_id = b.id";
		List<User> userList = jdbcTemplate.query(sql, new AutoBoxingRowMapper<User>(User.class));
		System.out.println(userList);
	}
	
}
